#!/bin/sh
# vim:set fileencoding=utf-8 et ts=4 sts=4 sw=4:

set -e

PREFERENCES=/etc/apt/listchanges.conf

. /usr/share/debconf/confmodule

runPython()
{
    temp=`tempfile -p aptlc -s .py`
    trap "rm -f $temp" EXIT
    cat > "$temp" << 'EOF'
#DEBCONF_HELPER_PY#
EOF
    python3 -B "$temp" "$@"
}

if which python3 2>/dev/null >&2; then
    runPython config "$PREFERENCES" "$@"
else
    echo "Deferring configuration of apt-listchanges until python3 is available" >&2
    exit 0
fi
